/*
  Name: Spark
  Description:
  Version: 1.1
  Author: Noritaka Horio
  Website: http://sharedhat.heteml.jp/
*/

float r = 50;
float x = 0;
float y = 0;

void setup() {
  size(300,165);
  background(#FFFFFF);
  smooth();
  noStroke();
  x = width / 2;
  y = height / 2;
  frameRate(15);
}

void draw() {
    drawEllipses();
    fadeOut();
}

void drawEllipses () {
  if (r >= 150) {
    noLoop();
  } else {
    drawEllipse(x, y, r);
    drawEllipse(x, y, r + 30);
    r = r + 10;
    fadeOut();
  }
}

void drawEllipse (float x, float y, float r) {

  fill(color(
    random(0, 255), random(0, 255),
    random(0, 255), random(0, 100)
  ));

  for (int i = 0; i < 36; i++) {
    float drawX = cos(i * 10) * r + x;
    float drawY = sin(i * 10) * r + y;
    ellipse(drawX, drawY, random(10, 20), random(10, 20));
  }
}

void fadeOut () {
  fill(color(255,255,255,10));
  rect(0, 0, width, height);
}
